package com.cloud.wms.ui.inside.transfer;

import android.os.Message;
import android.view.View;
import android.widget.CheckedTextView;
import android.widget.TextView;

import com.cloud.wms.R;
import com.cloud.wms.app.FineExApplication;
import com.cloud.wms.base.BaseBarActivity;
import com.cloud.wms.config.SpKey;
import com.cloud.wms.ui.inside.contract.TransferDownContact;
import com.cloud.wms.ui.inside.presenter.TransferDownPresenter;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by FC on 2021/5/17.
 * Desc：移库上下架设置
 */
public class TransferSettingActivity extends BaseBarActivity<TransferDownPresenter> implements TransferDownContact.View {
    @BindView(R.id.btn_yes)
    CheckedTextView btnYes;
    @BindView(R.id.btn_no)
    CheckedTextView btnNo;
    @BindView(R.id.btn_confirm)
    TextView btnConfirm;

    @Override
    protected String barTitle() {
        return "移库设置";
    }

    @Override
    protected int getResId() {
        return R.layout.activity_transfer_setting;
    }

    @Override
    protected void initEvent() {
        btnYes.setChecked(FineExApplication.component().kv().decodeBool(SpKey.TRANSFER_SCAN_CONTAINER));
        btnNo.setChecked(!FineExApplication.component().kv().decodeBool(SpKey.TRANSFER_SCAN_CONTAINER));
    }

    @OnClick({R.id.btn_yes, R.id.btn_no, R.id.btn_confirm})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_yes:
                btnYes.setChecked(true);
                btnNo.setChecked(false);
                break;
            case R.id.btn_no:
                btnNo.setChecked(true);
                btnYes.setChecked(false);
                break;
            case R.id.btn_confirm:
                FineExApplication.component().kv().encode(SpKey.TRANSFER_SCAN_CONTAINER, btnYes.isChecked());
                finish();
                break;
        }
    }

    @Override
    public void onSuccess(Message message) {
    }

    @Override
    protected void setupComponent() {
    }
}
